<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title">发货确认</h4>
</div>
<div class="modal-body">
    <span style="font-size: small;color: grey;padding-left: 5px">发货单号</span>
    <span style="padding-left: 5px">{{ $delivery->delivery_no }}</span>
    <span style="font-size: small;color: grey;padding-left: 5%">销售员</span>
    <span style="padding-left: 5px">{{ \App\Util\User::getUsernameById($delivery->seller_id) }}</span>
    <div class="box box-solid no-margin box-show">
        <div class="box-body">
            <h6 style="font-weight: bolder">收货人信息</h6>
            <div class="box-body table-responsive no-padding">
                <table class="table">
                    <thead>
                    <tr>
                        <th>国家</th>
                        <th>收货人</th>
                        <th width="15%">收货地址</th>
                        <th>州</th>
                        <th>城市</th>
                        <th>邮编</th>
                        <th>电话</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>{{ $delivery->receiver->country ?? '' }}</td>
                        <td>{{ $delivery->receiver->receiver ?? '' }}</td>
                        <td>{{ $delivery->receiver->address ?? '' }}</td>
                        <td>{{ $delivery->receiver->state ?? '' }}</td>
                        <td>{{ $delivery->receiver->city ?? '' }}</td>
                        <td>{{ $delivery->receiver->postcode ?? '' }}</td>
                        <td>{{ $delivery->receiver->phone ?? '' }}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="box box-solid no-margin box-show">
        <div class="box-body">
            <h6 style="font-weight: bolder">商品信息</h6>
            <div class="box-body table-responsive no-padding" style="max-height: 600px;">
                <table class="table table-hover">
                    <thead>
                    <tr>
                        <th>SKU</th>
                        <th width="25%">产品名称</th>
                        <th>申请发货数量</th>
                        <th>备货数量</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($delivery->detail as $item)
                        <tr>
                            <td>{{ $item->sku->psku_code ?? '' }}</td>
                            <td>{{ $item->sku->psku_cn ?? '' }}</td>
                            <td>{{ $item->apply_num }}</td>
                            <td><span class="label label-{{ $item->apply_num > $item->ship_num ? 'danger' : 'info'}}">{{ $item->ship_num }}</span></td>
                        </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<form id="ship-form" action="/xqc/customer-delivery/delivery-cn-ajax" method="post">
    <div class="modal-footer">
        {{ csrf_field() }}
        <input type="hidden" name="action" value="doShip">
        <input type="hidden" name="param" value="{{ $id }}">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
        <button type="submit" class="btn btn-primary">发货</button>
    </div>
</form>
<script language="JavaScript" type="text/javascript">
    $(function () {
        $("#ship-form").ajaxForm(function (data) {
            $("#listCommonModal").modal('hide');
            $(".modal-backdrop").remove();
            $('body').removeClass('modal-open');
            if (typeof data === 'object') {
                if (data.status) {
                    toastr.success(data.message);
                    $.pjax.reload('#pjax-container');
                } else {
                    swal(data.message, '', 'error');
                }
            }
        });
    });
</script>
